package com.lineage.server.serverpackets;

import com.lineage.server.model.Instance.L1DeInstance;

public class S_NPCPack_De extends ServerBasePacket {
  private static final int STATUS_POISON = 1;
  
  private static final int STATUS_INVISIBLE = 2;
  
  private static final int STATUS_PC = 4;
  
  private static final int STATUS_BRAVE = 16;
  
  private byte[] _byte = null;
  
  public S_NPCPack_De(L1DeInstance de) {
    int status = 4;
    if (de.getPoison() != null && de.getPoison().getEffectId() == 1)
      status |= 0x1; 
    if (de.isInvisble())
      status |= 0x2; 
    if (de.getBraveSpeed() == 1)
      status |= 0x10; 
    writeC(87);
    writeH(de.getX());
    writeH(de.getY());
    writeD(de.getId());
    writeH(de.getTempCharGfx());
    writeC(de.getStatus());
    writeC(de.getHeading());
    writeC(de.getChaLightSize());
    writeC(de.getMoveSpeed());
    writeD(0);
    writeH(de.getLawful());
    writeS(de.getNameId());
    writeS(de.getTitle());
    writeC(status);
    if (de.getClanid() > 0) {
      writeD(de.getEmblem().get_emblemid());
    } else {
      writeD(0);
    } 
    writeS(de.getClanname());
    writeS(null);
    writeC(0);
    writeC(255);
    writeC(0);
    writeC(0);
    writeC(0);
    writeC(255);
    writeC(255);
  }
  
  public byte[] getContent() {
    if (this._byte == null)
      this._byte = getBytes(); 
    return this._byte;
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
